﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace be.metanous.mvvm.converters
{
    public class BoolToDoubleConverter : IValueConverter
    {

        public double TrueValue { get; set; }

        public double FalseValue { get; set; }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool)
            {
                var isTrue = (bool) value;
                if (isTrue)
                {
                    return TrueValue;
                }
              
            }
            return FalseValue;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is double)
            {
                return ((double)value) == TrueValue;
            }
            return false;
        }
    }
}
